package com.electronic.enums;

import lombok.Getter;

/**
 * @Author: IFCA
 * @Description: 证书算法枚举
 */
@Getter
public enum CertAlgEnum {
    /**
     * 签名算法
     */
    SM2("SM2", 256, "SM3WithSM2"),
    RSA("RSA", 2048, "SHA256WithRSA");

    private String keyAlg;
    private int keySize;
    private String pkcs10SignAlg;

    CertAlgEnum(String keyAlg, int keySize, String pkcs10SignAlg) {
        this.keyAlg = keyAlg;
        this.keySize = keySize;
        this.pkcs10SignAlg = pkcs10SignAlg;
    }

    public static CertAlgEnum getCertAlgEnum(String keyAlg) {
        for (CertAlgEnum algEnum : CertAlgEnum.values()) {
            if (algEnum.keyAlg.equalsIgnoreCase(keyAlg)) {
                return algEnum;
            }
        }
        return null;
    }
}
